package com.cgbl.service.vm

import android.app.Application
import api.WorkServiceFactory
import com.robot.base.base.vm.GLBaseViewModel
import com.robot.base.common.api.AbstractViewModelSubscriber
import com.robot.base.configs.AppConstants
import com.robot.base.model.BaseResponse
import com.robot.base.model.MemberAdapterBean
import com.robot.base.model.TeamListBean
import com.robot.base.util.arouter.ARouterUtil
import me.goldze.mvvmhabit.binding.command.BindingAction
import me.goldze.mvvmhabit.binding.command.BindingCommand
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent

class SelectMemberViewModel(application: Application) : GLBaseViewModel(application) {

    val toAddTeamCommand = BindingCommand<Any>(BindingAction {
        ARouterUtil.goToActivity(AppConstants.Router.Project.A_ADD_TEAM)
    })



    val uc = UIChangeEvent()

    class UIChangeEvent {

        val teamMemberDataEvent = SingleLiveEvent<List<MemberAdapterBean>>()

    }

    fun fetchHomeMember() {
        WorkServiceFactory.getTeamByItemAccount().subscribe(object :
            AbstractViewModelSubscriber<BaseResponse<List<MemberAdapterBean>>>(this) {
            override fun onNext(t: BaseResponse<List<MemberAdapterBean>>) {
                uc.teamMemberDataEvent.postValue(t.data)
            }
        })
    }

}